package c.w.taxi;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import c.w.base.dto.BaseMessage;
import c.w.base.dto.ConnType;
import c.w.base.dto.person.PersonInfo;
import c.w.connection.ConnBaseService;
import c.w.connection.ConnInviteService;

import com.www.taxi.R;

public class InfoMainActivity extends Activity {

//	private static boolean start = true;
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_info);
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_info, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	// TODO Auto-generated method stub
    	
    	switch(item.getItemId()) {
    	case R.id.menu_settings: 
    		ConnBaseService baseService = new ConnBaseService();
    		for (int i = 0; i < 2; i++) {
    			if (baseService.call()) {
    				PersonInfo ps = new PersonInfo();
        			ps.setCarSharing(true);
        			ps.setAddress("四川省成都市双流县锦江路四段");
        			ps.setConnType(ConnType.FIRST);
        			ps.setDestination("川大望江校区");
        			ps.setStartingPoint("成信院");
        			ps.setLat(103.98978);
        			ps.setLng(30.580145);
        			ps.setPhoneNum("18200388683");
        			ps.setProductId("sichuanchengdu-00001");
        			
    				baseService.send(ps);	
        		}
    		}
    		
    		
            break;
            

    	case R.id.menu_invite:
    		ConnInviteService inviteService = new ConnInviteService();
    		
    		// 500个压力测试
    		for (int i = 0; i < 500; i++) {
    			if (inviteService.call()) {
        			BaseMessage bm2 = new BaseMessage();
        			
        			bm2.setBaseGrade(6666);
        			bm2.setFriendlyGrade(6666);
        			bm2.setVipGrade(6666);
        			
        			inviteService.send(bm2);
        		}
    		}
    		
    		break;
    	}
    	
    	return super.onOptionsItemSelected(item);
    }
    
}
